<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\ToolQuote;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class ToolQuoteController extends AdminController
{
    protected $title = '引用管理';
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new ToolQuote(), function (Grid $grid) {
            $grid->actions(function (Grid\Displayers\Actions $actions) {
//                $actions->disableDelete();
//                $actions->disableEdit();
                $actions->disableQuickEdit();
                $actions->disableView();
            });
            $grid->column('quote_id','ID')->sortable();
            $grid->column('quote_title','引用标题');
            $grid->column('quote_content','引用内容')->display(function ($content){
                return self::subtext(strip_tags($this->quote_content),10);
            });
            $grid->column('quote_sort','引用排序')->editable()->sortable();
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->column('is_top','是否置顶')->switch('#333');
            $grid->column('status','状态')->switch('#333');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('quote_id');

            });
        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new ToolQuote(), function (Form $form) {
            $form->display('quote_id','ID');
            $form->text('quote_title','引用标题');
            $form->editor('quote_content','引用内容');
            $form->number('quote_sort','排序');

            $form->display('created_at');
            $form->display('updated_at');
            $form->switch('is_top','是否置顶');
            $form->disableHeader();//去掉上面的
            $form->footer(function ($footer) {

                // 去掉`重置`按钮
                //$footer->disableReset();

                // 去掉`提交`按钮
                //$footer->disableSubmit();

                // 去掉`查看`checkbox
                $footer->disableViewCheck();

                // 去掉`继续编辑`checkbox
                $footer->disableEditingCheck();

                // 去掉`继续创建`checkbox
                $footer->disableCreatingCheck();
            });
        });
    }
}
